package com.sxsihe.heartmate;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import cn.pedant.SweetAlert.widget.SweetAlertDialog;

/**
 * Created by mac on 16/10/22.
 */
public class AboutActivity extends Activity implements View.OnClickListener {
    ImageView back_icon;
    RelativeLayout feedback_layout,check_update_layout,about_zhc_layout,service_num_layout;
    public void onCreate(Bundle bundle){
        super.onCreate(bundle);
        setContentView(R.layout.about);
        back_icon = (ImageView)findViewById(R.id.back_icon);
        back_icon.setOnClickListener(this);

        feedback_layout = (RelativeLayout)findViewById(R.id.feedback_layout);
        feedback_layout.setOnClickListener(this);
        check_update_layout = (RelativeLayout)findViewById(R.id.check_update_layout);
        check_update_layout.setOnClickListener(this);

        about_zhc_layout = (RelativeLayout)findViewById(R.id.about_zhc_layout);
        about_zhc_layout.setOnClickListener(this);
        service_num_layout = (RelativeLayout)findViewById(R.id.service_num_layout);
        service_num_layout.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        int version = Integer.valueOf(android.os.Build.VERSION.SDK);
        switch (v.getId()){
            case R.id.back_icon:
                finish();
                overridePendingTransition(R.anim.in_left, R.anim.out_right);
                break;
            case R.id.feedback_layout:
                Intent intent_f = new Intent();
                intent_f.setClass(this, UserInfoFeedbackActivity.class);
                startActivity(intent_f);
                if(version  >= 5) {
                    overridePendingTransition(R.anim.in_right, R.anim.out_left);
                }
                break;
            case R.id.check_update_layout:
                final AlertDialog myDialog = new AlertDialog.Builder(this).create();
                myDialog.show();
                myDialog.getWindow().setContentView(R.layout.check_update);

                myDialog.getWindow()
                        .findViewById(R.id.confirm)
                        .setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                myDialog.dismiss();
                            }
                        });

                break;
            case R.id.about_zhc_layout:
                Intent intent_a = new Intent();
                intent_a.setClass(this, AboutZHCActivity.class);
                startActivity(intent_a);
                if(version  >= 5) {
                    overridePendingTransition(R.anim.in_right, R.anim.out_left);
                }
                break;
            case R.id.service_num_layout:
                Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:4001003969"));
                startActivity(intent);
                break;
        }
    }

    public void onBackPressed() {
        super.onBackPressed();
        overridePendingTransition(R.anim.in_left, R.anim.out_right);
    }
}
